//
//  mSearchResult.swift
//  ShopIOS
//
//  Created by Apple on 2019/8/6.
//  Copyright © 2019 Apple. All rights reserved.
//

import Foundation
import SwiftyJSON

struct mSearchResult {
    var keywords: String?
    var orderKey: Int = 0
    var orderType: Int = 0
    var Product = [mSearchProduct]()
    var Total: Int = 0
    var b_id: Int = 0
    var a_id: String?
    var Success: String?
    var cid: Int = 0
    
    init(json: JSON) {
        keywords = json["keywords"].stringValue
        orderKey = json["orderKey"].intValue
        orderType = json["orderType"].intValue
        Product = json["Product"].arrayValue.compactMap({ mSearchProduct(json: $0)})
        Total = json["Total"].intValue
        b_id = json["b_id"].intValue
        a_id = json["a_id"].stringValue
        Success = json["Success"].stringValue
        cid = json["cid"].intValue
    }
}

struct mSearchCashDepositsServer {
    var IsCustomerSecurity: Bool = false
    var IsSevenDayNoReasonReturn: Bool = false
    var IsTimelyShip: Bool = false
    var CanSelfTake: Bool = false
    
    init(json: JSON) {
        IsCustomerSecurity = json["IsCustomerSecurity"].boolValue
        IsSevenDayNoReasonReturn = json["IsSevenDayNoReasonReturn"].boolValue
        IsTimelyShip = json["IsTimelyShip"].boolValue
        CanSelfTake = json["CanSelfTake"].boolValue
    }
}

struct mSearchProduct {
    var IsFreight: Bool = false
    var Comments: Int = 0
    var MinSalePrice: Int = 0
    var ProductAddress: String?
    var ShopId: Int = 0
    var cartquantity: Int = 0
    var VshopId: Int = 0
    var HasSKU: Bool = false
    var ThirdCateId: Int = 0
    var ShopName: String?
    var SaleCount: Int = 0
    var ProductName: String?
    var ProductId: Int = 0
    var SalePrice: Int = 0
    var SkuId: String?
    var ImagePath: String?
    var ProductAttributeInfos = [String]()
    var CashDepositsServer: mSearchCashDepositsServer?
    
    init(json: JSON) {
        IsFreight = json["IsFreight"].boolValue
        Comments = json["Comments"].intValue
        MinSalePrice = json["MinSalePrice"].intValue
        ProductAddress = json["ProductAddress"].stringValue
        ShopId = json["ShopId"].intValue
        cartquantity = json["cartquantity"].intValue
        VshopId = json["VshopId"].intValue
        HasSKU = json["HasSKU"].boolValue
        ThirdCateId = json["ThirdCateId"].intValue
        ShopName = json["ShopName"].stringValue
        SaleCount = json["SaleCount"].intValue
        ProductName = json["ProductName"].stringValue
        ProductId = json["ProductId"].intValue
        SalePrice = json["SalePrice"].intValue
        SkuId = json["SkuId"].stringValue
        ImagePath = json["ImagePath"].stringValue
        ProductAttributeInfos = json["ProductAttributeInfos"].arrayValue.compactMap({$0.stringValue})
        CashDepositsServer = mSearchCashDepositsServer(json: json["CashDepositsServer"])
    }
}
